﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace EFong.Contract
{
    [DataContract]
    public class FlightChange : Order
    {
        public FlightChange() 
        {
            OrderType = "飞机票改票";
        }

        private decimal _vendorPrice;
        [DataMember]
        public decimal VendorPrice
        {
            get { return _vendorPrice; }
            set { _vendorPrice = value; }
        }

        private Currency _vendorCurrency;
        [DataMember]
        public Currency VendorCurrency
        {
            get { return _vendorCurrency; }
            set { _vendorCurrency = value; }
        }

        private decimal _price;
        [DataMember]
        public decimal Price
        {
            get { return _price; }
            set { _price = value; }
        }

        private Currency _currency;
        [DataMember]
        public Currency Currency
        {
            get { return _currency; }
            set { _currency = value; }
        }

        private BankAccount _bankAccount;
        [DataMember]
        public BankAccount BankAccount
        {
            get { return _bankAccount; }
            set { _bankAccount = value; }
        }

        private string _paymentType = string.Empty;
        [DataMember]
        public string PaymentType
        {
            get { return _paymentType; }
            set { _paymentType = value; }
        }

        private decimal _exchangeRate = 1;
        [DataMember]
        public decimal ExchangeRate
        {
            get { return _exchangeRate; }
            set { _exchangeRate = value; }
        }

        private Vendor _vendor;
        [DataMember]
        public Vendor Vendor
        {
            get { return _vendor; }
            set { _vendor = value; }
        }

        private Customer _customer;
        [DataMember]
        public Customer Customer
        {
            get { return _customer; }
            set { _customer = value; }
        }

        //private FlightOrderDatail _flightOrderDatail;
        //[DataMember]
        //public FlightOrderDatail FlightOrderDetail
        //{
        //    get { return _flightOrderDatail; }
        //    set { _flightOrderDatail = value; }
        //}

        /// <summary>
        /// 利润
        /// </summary>
        public decimal? Profit
        {
            get
            {
                if (Currency != VendorCurrency)
                {
                    if (ExchangeRate == 0)
                        return null;

                    return Price - VendorPrice * ExchangeRate;
                }
                else
                    return Price - VendorPrice;
            }
        }

        public override bool Equals(object obj)
        {
            FlightChange temp = obj as FlightChange;
            if (temp == null)
                return false;
            return (this.ID.Equals(temp.ID));
        }
    }
}
